| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkGraphics::MeshInputLayout Class Referencefinal

Describes the layout of data inside a mesh. More...

## Public Member Functions
| MeshInputLayout () noexcept
unsigned long long | getHash () const
nkMemory::StringView | getPositionAttributeName () const
nkMemory::StringView | getNormalAttributeName () const
nkMemory::StringView | getTexCoordAttributeName () const
unsigned int | getComputedAttributeOffset (nkMemory::StringView name) const
void | setAttribute (const MeshInputLayoutAttribute &attribute, unsigned int index)
void | setPositionAttributeName (nkMemory::StringView value)
void | setNormalAttributeName (nkMemory::StringView value)
void | setTexCoordAttributeName (nkMemory::StringView value)
void | addAttribute (const MeshInputLayoutAttribute &attribute)
const MeshInputLayoutAttribute * | getAttribute (unsigned int index) const
const MeshInputLayoutAttribute * | getAttribute (nkMemory::StringView name) const
unsigned int | getAttributeCount () const
unsigned int | getTotalDeclarationSlots () const
void | removeAttribute (unsigned int index)
void | removeAttribute (nkMemory::StringView name)
bool | hasAttribute (nkMemory::StringView name, unsigned int semanticIndex=0u) const
bool | operator< (const MeshInputLayout &other) const
bool | operator== (const MeshInputLayout &other) const

## Detailed Description

Describes the layout of data inside a mesh.

## Constructor & Destructor Documentation

## ◆ MeshInputLayout()

nkGraphics::MeshInputLayout::MeshInputLayout | ( |  | ) |
| noexcept

Default constructor.

## Member Function Documentation

## ◆ getHash()

unsigned long long nkGraphics::MeshInputLayout::getHash | ( |  | ) | const

Returns
  A hash of the layout's state, which depends on the attributes inside.

## ◆ getPositionAttributeName()

nkMemory::StringView nkGraphics::MeshInputLayout::getPositionAttributeName | ( |  | ) | const

Returns
  The name of the attribute that should be considered as position.

## ◆ getNormalAttributeName()

nkMemory::StringView nkGraphics::MeshInputLayout::getNormalAttributeName | ( |  | ) | const

Returns
  The name of the attribute that should be considered as normal.

## ◆ getTexCoordAttributeName()

nkMemory::StringView nkGraphics::MeshInputLayout::getTexCoordAttributeName | ( |  | ) | const

Returns
  The name of the attribute that should be considered as texture coordinate.

## ◆ getComputedAttributeOffset()

unsigned int nkGraphics::MeshInputLayout::getComputedAttributeOffset | ( | nkMemory::StringView | name | ) | const

Computes the offset of one attribute by its name, within its buffer.

Parameters

  name | The name of the attribute which offset is to be computed.

Returns
  The computed offset in bytes. If the attribute is not found, it will return 0.

Remarks
  This method always returns a computed offset value, even for attributes for which client code did not define an offset (which will be automatically computed). The offset will be based on the preceding attributes within the same vertex buffer slot.

## ◆ setAttribute()

void nkGraphics::MeshInputLayout::setAttribute | ( | const MeshInputLayoutAttribute & | attribute,
|  | unsigned int | index
| ) |  |

Sets an attribute at a given index, overriding its values.

Parameters

  attribute | The new values to set.
  index | The index of the attribute to override, in the attribute list.

## ◆ setPositionAttributeName()

void nkGraphics::MeshInputLayout::setPositionAttributeName | ( | nkMemory::StringView | value | ) |

Sets the name of the contained attribute that should be considered as providing position information.

Parameters

  value | The name of the attribute.

## ◆ setNormalAttributeName()

void nkGraphics::MeshInputLayout::setNormalAttributeName | ( | nkMemory::StringView | value | ) |

Sets the name of the contained attribute that should be considered as providing normal information.

Parameters

  value | The name of the attribute.

## ◆ setTexCoordAttributeName()

void nkGraphics::MeshInputLayout::setTexCoordAttributeName | ( | nkMemory::StringView | value | ) |

Sets the name of the contained attribute that should be considered as providing texture coordinate information.

Parameters

  value | The name of the attribute.

## ◆ addAttribute()

void nkGraphics::MeshInputLayout::addAttribute | ( | const MeshInputLayoutAttribute & | attribute | ) |

Adds an attribute to the layout's list.

Parameters

  attribute | The attribute to append.

Remarks
  Attributes have various mechanism to compute offsets and strides if this work is left to the engine. Their order of appearance in the list is important in such case. If you use the feature, be sure to add the attributes in their order of appearance in their respective buffers.

## ◆ getAttribute() [1/2]

const MeshInputLayoutAttribute* nkGraphics::MeshInputLayout::getAttribute | ( | unsigned int | index | ) | const

Allows to access an attribute for reading operations.

Parameters

  index | The list index of the attribute to access.

Returns
  The attribute at given index if available, nullptr else.

## ◆ getAttribute() [2/2]

const MeshInputLayoutAttribute* nkGraphics::MeshInputLayout::getAttribute | ( | nkMemory::StringView | name | ) | const

Allows to access an attribute for reading operations.

Parameters

  name | The name of the attribute to access.

Returns
  The attribute requested if available, nullptr else.

## ◆ getAttributeCount()

unsigned int nkGraphics::MeshInputLayout::getAttributeCount | ( |  | ) | const

Returns
  The total number of attributes in the layout.

## ◆ getTotalDeclarationSlots()

unsigned int nkGraphics::MeshInputLayout::getTotalDeclarationSlots | ( |  | ) | const

Returns
  The total number of slots taken by the attributes.

Remarks
  Slots corresponds to the total number of nkFloat4 taken by the layout. For instance, a 4x4 matrix takes 4 slots, while a vector will take 1. This function provides the total number of slots taken by all attributes in the layout.

## ◆ removeAttribute() [1/2]

void nkGraphics::MeshInputLayout::removeAttribute | ( | unsigned int | index | ) |

Removes an attribute from the list.

Parameters

  index | The index of the attribute to remove.

## ◆ removeAttribute() [2/2]

void nkGraphics::MeshInputLayout::removeAttribute | ( | nkMemory::StringView | name | ) |

Removes an attribute from the list.

Parameters

  name | The name of the attribute to remove.

## ◆ hasAttribute()

bool nkGraphics::MeshInputLayout::hasAttribute | ( | nkMemory::StringView | name,
|  | unsigned int | semanticIndex = `0u`
| ) |  | const

Checks if layout has a given attribute available.

Parameters

  name | The name of the attribute to check for.
  semanticIndex | The index of the attribute to check for. This index is typically appended at the end of the name, if necessary.

Returns
  Whether the attribute is available in the layout (true) or not (false).

## ◆ operator<()

bool nkGraphics::MeshInputLayout::operator< | ( | const MeshInputLayout & | other | ) | const

Parameters

  other | The layout to compare with.

Returns
  Whether the layout is to be considered inferior to the other layout.

## ◆ operator==()

bool nkGraphics::MeshInputLayout::operator== | ( | const MeshInputLayout & | other | ) | const

Parameters

  other | The layout to compare with.

Returns
  Whether the layout is equal to the other layout.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsGraphics/Meshes/InputLayouts/MeshInputLayout.h